<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
		<title>查报告</title>
		<meta http-equiv="expires" content="0">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<link rel="stylesheet" href="../../css/reset.css" />
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/iconfont.css" />
		<link rel="stylesheet" href="../../css/cmms.css" />
		<link rel="stylesheet" href="../../css/patient/reportResult.css"/>
		<script src="../../js/vconsole.min.js"></script>
	</head>
	<style type="text/css">
		
	</style>
	<body>
		<div class="mui-content" id="reportResult" v-cloak>
		    <div class="wrap">
		    	<p class="top"><span>报告单查询结果</span></p>
		    	<ul v-show="sampleInfo.length>0">
		    		<li class="mui-table-view-cell" v-for="samp in sampleInfo" @tap="toDetail(samp.SampleInfoID,samp.ID)">
		    			<div class="left">
		    				<p>
			    				<span class="name">{{samp.PatientName}}</span>
			    				<span class="time">{{samp.SexName}}</span>
			    				<span class="time">{{samp.Age}}{{samp.AgeTypeName}}</span>
			    			</p>
			    			<p>
			    				<span class="name">条形码：{{samp.Barcode}}</span>
			    				<span class="time">{{samp.CheckTime}}</span>
			    			</p>
		    			</div>
		    			<div class="right"><i class="iconfont icon-chakangengduo"></i></div>
		    		</li>
		    	</ul>
		    	<div class="noData" v-show="!sampleInfo.length>0">
		    		<p>暂未查询到数据！</p>
		    	</div>
		    </div>
		</div>
		<script src="../../js/mui.min.js"></script>
		<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
		<script src="../../js/vue.js"></script>
		<script src="../../js/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/cmms.js?time=333"></script>
		<script>
			new Vue({
				el:"#reportResult",
				data:{
					startTime:'',
					endTime:'',
					barCode:'',
					patientName:'',
					hospitalCode:'',
					token:'',
					patientName:'',
					sampleInfo:[]
				},
				mounted(){
//					var vConsole = new VConsole();
					this.init();
					this.getUrl();
					this.loadInfo();
				},
				methods:{
					init(){
						let _this = this;
						_this.token = localStorage.getItem('hospi_token');
						console.log(_this.token);
					},
					/*获取URI后的hospitalCode*/
					getUrl(){
						let _this=this;
						var url = location.search; //获取url中"?"符后的字串    
						var theRequest = new Object();  
//						console.log(url);
					   	if (url.indexOf("?") != -1) {   
					      var str = url.substr(1);  
//					      console.log(str);
					      strs = str.split("&");  
					      for(var i = 0; i < strs.length; i ++) {   
					         theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);   
					      } 
					   	}   
//					   	console.log(theRequest);
					   	_this.startTime = theRequest.BeginDate;
					   	_this.endTime = theRequest.EndDate;
					   	_this.barCode = theRequest.Barcode;
					   	_this.patientName = theRequest.PatientName;
					   	_this.hospitalCode = theRequest.HospitalCode;
					   	console.log(_this.startTime);
					   	console.log(_this.endTime);
					   	console.log(_this.barCode);
					   	console.log(_this.patientName);
					   	console.log(_this.hospitalCode);
					},
					loadInfo(){
						let _this = this;
						$.ajax({
					   		type:"get",
					   		url:"https://antreport.ulabmed.com:8081/ReportAshx/ReportHandler.ashx",
					   		async:true,
					   		data:{
					   			action:'GetSampleInfo',
								BeginDate:_this.startTime,
								EndDate:_this.endTime,
								Barcode:_this.barCode,
								PatientName:_this.patientName,
								HospitalCode:_this.hospitalCode,
								Token:_this.token,
								jsonpCallback:"cb"
					   		},
					   		dataType:"jsonp",
//					   		contentType:"application/x-www-form-urlencoded",
					   		success:function(data){
					   			console.log(data[0].Value);
					   			if(data[0].Value.SampleInfo.length>0){
					   				mui.toast(data[0].Msg);
					   			}
					   			
					   			var data = data[0];
					   			_this.sampleInfo = data.Value.SampleInfo;
					   		},
					   		error:function(err){
					   			console.log(err)
					   		}
					   });
					},
					toDetail(SampleInfoId,sID){
						let _this = this
						location.href="reportDetail.html?SampleInfoId="+SampleInfoId+"&HospitalCode="+_this.hospitalCode+'&sid='+sID;
					}
				}
			})
		</script>
	</body>
</html>